#include <IRremote.h>

IRrecv irrecv_5(5);
decode_results results_5;

long ir_value;
volatile int led;
volatile boolean ledst;

void setup(){
  led = 0;
  ledst = 0;
  Serial.begin(9600);
  pinMode(10, OUTPUT);
  irrecv_5.enableIRIn();
}

void loop(){
  if (irrecv_5.decode(&results_5)) {
    ir_value=results_5.value;
    String type="UNKNOWN";
    String typelist[14]={"UNKNOWN", "NEC", "SONY", "RC5", "RC6", "DISH", "SHARP", "PANASONIC", "JVC", "SANYO", "MITSUBISHI", "SAMSUNG", "LG", "WHYNTER"};
    if(results_5.decode_type>=1&&results_5.decode_type<=13){
      type=typelist[results_5.decode_type];
    }
    Serial.print("IR TYPE:"+type+"  ");
    Serial.println(ir_value,HEX);
    if (ir_value == 0xFF629D) {
      ledst = !ledst;
      led = ledst * 128;

    }
    if (ledst == 1) {
      if (ir_value == 0xFFE21D) {
        led = constrain(led + 20, 0, 255);

      }
      if (ir_value == 0xFFA25D) {
        led = constrain(led - 20, 0, 255);

      }
      Serial.println(led);

    }
    digitalWrite(10,led);
    irrecv_5.resume();
  } else {
  }

}
